import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';
import { HomeCompoentComponent } from './home-compoent/home-compoent.component';
import { LoginComponentComponent } from './login-component/login-component.component';

import { ManagementComponentComponent } from './management-component/management-component.component';
import { UserManagementComponntComponent } from './user-management-componnt/user-management-componnt.component';
import { ProduceComponentComponent } from './produce-component/produce-component.component';
import { ExitComponentComponent } from './exit-component/exit-component.component';
import { RouterModule, Routes } from '@angular/router';
import { LoginGuard } from './login.guard';
import { AuthService } from './auth.service';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import{HttpClientModule}from'@angular/common/http'

const mgtChildrenRoutes:Routes=[
  {path:'user',component:UserManagementComponntComponent},
  {path:'product',component:ProduceComponentComponent},
  {path:'exit',component:ExitComponentComponent},
  {path:'',redirectTo:'user',pathMatch:'full'}

];

const routes:Routes=[
  {path:'home', component:HomeCompoentComponent},
  {path:'', redirectTo:'home', pathMatch:'full'},
  {path:'login',component:LoginComponentComponent},
  {
    path:'management',
   component:ManagementComponentComponent,
   children:mgtChildrenRoutes,
   canActivate:[LoginGuard]
   

  }
];

 
@NgModule({
  declarations: [
    AppComponent,
    HomeCompoentComponent,
    LoginComponentComponent,
    ManagementComponentComponent,
    UserManagementComponntComponent,
    ProduceComponentComponent,
    ExitComponentComponent,
   
  ],
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot(routes),//<--routes
    HttpClientModule

  ],
  providers: [LoginGuard,AuthService,],
  bootstrap: [AppComponent]
})
export class AppModule { }
